Arrow keys / Click to navigate

Module 6: Containers

Advanced Architecting on AWS

ECS β€’ EKS β€’ Fargate β€’ ECR β€’ Networking β€’ Service Mesh

🎯 Module Objectives

πŸ“¦ Amazon ECS Architecture

ComponentRoleDetails
Task DefinitionBlueprintContainer image, CPU/memory, ports, IAM role, volumes
TaskRunning instanceOne or more containers from a task definition
ServiceDesired stateMaintains N tasks, integrates with ALB, auto-scales
ClusterLogical groupingEC2 instances or Fargate β€” infrastructure for tasks
Capacity ProviderInfrastructure strategyFargate, Fargate Spot, or ASG-backed EC2
Analogy: Task Definition = recipe, Task = a dish being prepared, Service = a restaurant that always keeps 5 dishes ready, Cluster = the kitchen.

☸️ Amazon EKS

ECS vs. EKS decision: ECS = simpler, AWS-native, lower operational overhead. EKS = Kubernetes standard, portable, richer ecosystem, more complexity.

🌐 Container Networking

ModeECSBehavior
awsvpcRequired for FargateEach task gets its own ENI + private IP. Full SG support.
bridgeEC2 launch typeDocker bridge network. Port mapping required. Less isolation.
hostEC2 launch typeContainer uses host network. Best performance, no isolation.

πŸ•ΈοΈ Service Mesh β€” AWS App Mesh

When to use: Microservices architectures with 10+ services needing fine-grained traffic control, mutual TLS, and centralized observability. For simpler setups, ALB + Cloud Map may suffice.

πŸ’» Demo: ECS Service Deployment

# Register a task definition
aws ecs register-task-definition --cli-input-json file://task-def.json

# Create an ECS service with ALB
aws ecs create-service --cluster prod-cluster \
  --service-name web-api --task-definition web-api:3 \
  --desired-count 3 --launch-type FARGATE \
  --network-configuration "awsvpcConfiguration={subnets=[subnet-xxx],securityGroups=[sg-xxx],assignPublicIp=DISABLED}" \
  --load-balancers "targetGroupArn=arn:...,containerName=web,containerPort=8080"

# Scale the service
aws ecs update-service --cluster prod-cluster \
  --service web-api --desired-count 5

πŸ§ͺ Knowledge Check

Q1: An ECS task needs to communicate with an RDS database. The security team requires that network access be controlled at the task level. Which network mode should be used?

A) bridge   B) host   C) awsvpc   D) none

C) awsvpc β€” The awsvpc mode gives each task its own ENI with a private IP and security group. This enables task-level network controls, allowing the RDS security group to reference the task's SG.

Q2: What is the key advantage of EKS Fargate profiles over managed node groups?

A) Lower cost   B) No node management β€” serverless per-pod compute   C) GPU support   D) Faster scaling

B) No node management β€” serverless per-pod compute β€” Fargate profiles eliminate EC2 node management entirely. Each pod runs in its own isolated micro-VM. Trade-off: no DaemonSets, no GPU, limited storage options.

πŸ“ Module 6 Summary

ECS

Task definitions β†’ Tasks β†’ Services. Capacity providers (Fargate/EC2). awsvpc for isolation.

EKS

Managed K8s control plane. Node groups or Fargate. VPC CNI for pod networking. Add-ons managed.

ECR & Networking

Private registries. Image scanning. awsvpc = ENI per task. SG-for-pods in EKS.

Service Mesh

App Mesh with Envoy sidecars. Traffic management, mTLS, observability for microservices.

Click anywhere to close